import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/account/page/account_income/view.dart';
import 'package:honeypotflutter/public/public_get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/loginInfo/bussine_userInfo.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_switchMonry.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/public/public_total.dart';
import 'package:honeypotflutter/router/bussine_router_url.dart';
import 'logic.dart';

class AccountBalancePage extends StatefulWidget {
  const AccountBalancePage({Key? key}) : super(key: key);

  @override
  State<AccountBalancePage> createState() => _AccountBalancePageState();
}

class _AccountBalancePageState extends State<AccountBalancePage> {
  final AccountBalanceLogic logic = Get.put(AccountBalanceLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "账户余额"),
      body: HLScrollView(
        padding: EdgeInsets.all(16),
        children: [
          MGCard(
            backColor: MGColors.themeColor.withOpacity(0.7),
            padding: EdgeInsets.only(top: 30, bottom: 15),
            children: [
              GetBuilder<UserInfoLogic>(
                  init: UserInfoLogic(),
                  builder: (controller) {
                    return MGSwitchMonry(
                      color: MGColors.text1Color,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      monry: controller.userInfo.accountBalance,
                    );
                  }),
              Row(
                children: [
                  TextButton(
                      onPressed: () {
                        HLGet.toNamed(MGRouterUrl.recharge);
                      },
                      child: Text(
                        "充值",
                        style: TextStyle(color: MGColors.text1Color),
                      )),
                  Container(
                    color: MGColors.text1Color,
                    width: 2,
                    height: 10,
                  ),
                  TextButton(
                      onPressed: () {
                        HLGet.toNamed(MGRouterUrl.billing);
                      },
                      child: Text(
                        "明细",
                        style: TextStyle(color: MGColors.text1Color),
                      ))
                ],
                mainAxisAlignment: MainAxisAlignment.end,
              )
            ],
          ),
          SizedBox(height: 20),
          MGCard(
            children: [
              MGItems(
                leadTitle: "我的收入",
                trailingIcon: MGImage.image("public_next"),
                showBottomSplit: true,
                action: () {
                  Get.to(AccountIncomePage());
                },
              ),
              MGItems(
                leadTitle: "实名认证",
                trailingTitle: "已认证",
                showBottomSplit: true,
                action: () {
                  HLTotal.total("您已认证");
                },
              ),
              MGItems(
                leadTitle: "开具发票",
                trailingIcon: MGImage.image("public_next"),
                action: () {
                  HLTotal.total("暂未开放");
                },
              )
            ],
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<AccountBalanceLogic>();
    super.dispose();
  }
}
